package openvino

import (
	"fmt"
)

// DeviceType represents the device type for inference
type DeviceType string

const (
	// DeviceAuto - Automatic device selection (default)
	DeviceAuto DeviceType = "AUTO"
	// DeviceGPU - GPU device
	DeviceGPU DeviceType = "GPU"
	// DeviceNPU - NPU device (Neural Processing Unit)
	DeviceNPU DeviceType = "NPU"
	// DeviceCPU - CPU device
	DeviceCPU DeviceType = "CPU"
)

// IsValid checks if the device type is valid
func (d DeviceType) IsValid() bool {
	switch d {
	case DeviceAuto, DeviceGPU, DeviceNPU, DeviceCPU:
		return true
	default:
		return false
	}
}

// String returns the string representation of the device type
func (d DeviceType) String() string {
	return string(d)
}

// ParseDeviceType parses a string to DeviceType
func ParseDeviceType(s string) (DeviceType, error) {
	dt := DeviceType(s)
	if !dt.IsValid() {
		return "", fmt.Errorf("invalid device type: %s", s)
	}
	return dt, nil
}

// ModelConfig represents the configuration for OpenVINO model
type ModelConfig struct {
	// ModelPath is the path to the OpenVINO model file (.xml)
	ModelPath string
	// Device is the device type for inference (AUTO, GPU, NPU, CPU)
	Device DeviceType
	// NumThreads is the number of threads for CPU inference (0 = auto)
	NumThreads int
	// GPUStreams is the number of GPU streams (0 = auto)
	GPUStreams int
	// NPUStreams is the number of NPU streams (0 = auto)
	NPUStreams int
}

// Detection represents a single detection result
type Detection struct {
	// ClassID is the class ID of the detection
	ClassID int
	// ClassName is the class name of the detection
	ClassName string
	// Confidence is the confidence score (0.0-1.0)
	Confidence float32
	// Box is the bounding box
	Box Box
}

// Box represents a bounding box
type Box struct {
	X      int
	Y      int
	Width  int
	Height int
}

// InferenceResult represents the result of inference
type InferenceResult struct {
	// Detections is the list of detected objects
	Detections []Detection
	// ProcessTimeMs is the processing time in milliseconds
	ProcessTimeMs float64
	// Device is the device used for inference
	Device string
}

// DeviceInfo represents information about available devices
type DeviceInfo struct {
	// Name is the device name
	Name string
	// Type is the device type
	Type string
	// Available indicates if the device is available
	Available bool
	// Properties contains device-specific properties
	Properties map[string]string
}

